/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package cards;

import enums.CardTypes;
import enums.TerminalCardTypes;
import java.util.Calendar;
import java.util.Date;

/**
 *
 * @author Oksana_Moroz
 */
public class TerminalCard extends Card {

    protected Date issue;
    protected TerminalCardTypes terminalCardTypes;
    
    public TerminalCard(long id, CardTypes type, TerminalCardTypes terminalCardTypes) {
        super(id, type);
        this.issue = Calendar.getInstance().getTime();
        this.terminalCardTypes = terminalCardTypes;
    }

    @Override
    public boolean makeTrip() {        
        Date current = Calendar.getInstance().getTime();
        long diff = current.getTime() - issue.getTime();
        int days = (int) (diff / (24 * 60 * 60 * 1000));
        return days <= terminalCardTypes.getDays();
    }
    
    @Override
    public String toString() {
        return "" + terminalCardTypes.getDays() + "-days terminal card, id = " + id + ", type = " + type;
    }
}
